home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 85 / CD Actual 85 Febrero 2004.iso / Experto / Apache / apache_2.0.48-win32-x86-no_ssl.msi / Data.Cab / F251767_apr_rmm.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-12-31  |  6.4 KB  |  172 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  */
  54.  
  55. #ifndef APR_RMM_H
  56. #define APR_RMM_H
  57. /** 
  58.  * @file apr_rmm.h
  59.  * @brief APR-UTIL Relocatable Memory Management Routines
  60.  */
  61. /**
  62.  * @defgroup APR_Util_RMM Relocatable Memory Management Routines
  63.  * @ingroup APR_Util
  64.  * @{
  65.  */
  66.  
  67. #include "apr.h"
  68. #include "apr_pools.h"
  69. #include "apr_errno.h"
  70. #include "apu.h"
  71. #include "apr_anylock.h"
  72.  
  73. #ifdef __cplusplus
  74. extern "C" {
  75. #endif /* __cplusplus */
  76.  
  77. /** Structure to access Relocatable, Managed Memory */
  78. typedef struct apr_rmm_t apr_rmm_t;
  79.  
  80. /** Fundemental allocation unit, within a spcific apr_rmm_off_t */
  81. typedef apr_size_t   apr_rmm_off_t;
  82.  
  83. /**
  84.  * Initialize a relocatable memory block to be managed by the apr_rmm API.
  85.  * @param rmm The relocatable memory block
  86.  * @param lock An apr_anylock_t of the appropriate type of lock
  87.  * @param membuf The block of relocateable memory to be managed
  88.  * @param memsize The size of relocateable memory block to be managed
  89.  * @param cont The pool to use for local storage and management
  90.  */
  91. APU_DECLARE(apr_status_t) apr_rmm_init(apr_rmm_t **rmm, apr_anylock_t *lock,
  92.                                        void* membuf, apr_size_t memsize, 
  93.                                        apr_pool_t *cont);
  94.  
  95. /**
  96.  * Destroy a managed memory block.
  97.  * @param rmm The relocatable memory block to destroy
  98.  */
  99. APU_DECLARE(apr_status_t) apr_rmm_destroy(apr_rmm_t *rmm);
  100.  
  101. /**
  102.  * Attach to a relocatable memory block already managed by the apr_rmm API.
  103.  * @param rmm The relocatable memory block
  104.  * @param lock An apr_anylock_t of the appropriate type of lock
  105.  * @param membuf The block of relocateable memory already under management
  106.  * @param cont The pool to use for local storage and management
  107.  */
  108. APU_DECLARE(apr_status_t) apr_rmm_attach(apr_rmm_t **rmm, apr_anylock_t *lock,
  109.                                          void* membuf, apr_pool_t *cont);
  110.  
  111. /**
  112.  * Detach from the managed block of memory.
  113.  * @param rmm The relocatable memory block to detach from
  114.  */
  115. APU_DECLARE(apr_status_t) apr_rmm_detach(apr_rmm_t *rmm);
  116.  
  117. /**
  118.  * Allocate memory from the block of relocatable memory.
  119.  * @param rmm The relocatable memory block
  120.  * @param reqsize How much memory to allocate
  121.  */
  122. APU_DECLARE(apr_rmm_off_t) apr_rmm_malloc(apr_rmm_t *rmm, apr_size_t reqsize);
  123.  
  124. /**
  125.  * Realloc memory from the block of relocatable memory.
  126.  * @param rmm The relocatable memory block
  127.  * @param entity The memory allocation to realloc
  128.  * @param reqsize The new size
  129.  */
  130. APU_DECLARE(apr_rmm_off_t) apr_rmm_realloc(apr_rmm_t *rmm, void *entity, apr_size_t reqsize);
  131.  
  132. /**
  133.  * Allocate memory from the block of relocatable memory and initialize it to zero.
  134.  * @param rmm The relocatable memory block
  135.  * @param reqsize How much memory to allocate
  136.  */
  137. APU_DECLARE(apr_rmm_off_t) apr_rmm_calloc(apr_rmm_t *rmm, apr_size_t reqsize);
  138.  
  139. /**
  140.  * Free allocation returned by apr_rmm_malloc or apr_rmm_calloc.
  141.  * @param rmm The relocatable memory block
  142.  * @param entity The memory allocation to free
  143.  */
  144. APU_DECLARE(apr_status_t) apr_rmm_free(apr_rmm_t *rmm, apr_rmm_off_t entity);
  145.  
  146. /**
  147.  * Retrieve the physical address of a relocatable allocation of memory
  148.  * @param rmm The relocatable memory block
  149.  * @param entity The memory allocation to free
  150.  */
  151. APU_DECLARE(void *) apr_rmm_addr_get(apr_rmm_t *rmm, apr_rmm_off_t entity);
  152.  
  153. /**
  154.  * Compute the offset of a relocatable allocation of memory
  155.  * @param rmm The relocatable memory block
  156.  * @param entity The physical address to convert to an offset
  157.  */
  158. APU_DECLARE(apr_rmm_off_t) apr_rmm_offset_get(apr_rmm_t *rmm, void* entity);
  159.  
  160. /**
  161.  * Compute the required overallocation of memory needed to fit n allocs
  162.  * @param n The number of alloc/calloc regions desired
  163.  */
  164. APU_DECLARE(apr_size_t) apr_rmm_overhead_get(int n);
  165.  
  166. #ifdef __cplusplus
  167. }
  168. #endif
  169. /** @} */
  170. #endif  /* ! APR_RMM_H */
  171.  
  172.